package com.example.word.bean;

import com.example.word.util.DateUtils;

import org.litepal.annotation.Column;
import org.litepal.crud.DataSupport;

import java.io.Serializable;
import java.util.List;


/**
 * 学习计划
 */
public class StudyPlan extends DataSupport implements Serializable {
    private String account;//用户账号
    private int dayTask;//每日学习数量
    private String dict;//选择要学习的词汇

    @Column(ignore = true)
    private int todayCount;//今日已经学习数量
    @Column(ignore = true)
    private int reviewCount;//待复习数量
    @Column(ignore = true)
    private int totalCount;//总学习数量

    public static StudyPlan queryCurrentUserPlan(String account) {
        StudyPlan studyPlan = where("account = ?", account).findFirst(StudyPlan.class);

        int today = where("account = ? and date = ?", account, DateUtils.dateString()).count(Browse.class);
        int total = where("account = ?", account).count(Browse.class);
        int review = Browse.where("account = ? and isReview != 'Y'", account).count(Browse.class);

        studyPlan.setTodayCount(today);
        studyPlan.setTotalCount(total);
        studyPlan.setReviewCount(review);
        return studyPlan;
    }

    public int getReviewCount() {
        return reviewCount;
    }

    public void setReviewCount(int reviewCount) {
        this.reviewCount = reviewCount;
    }

    public int getTodayCount() {
        return todayCount;
    }

    public void setTodayCount(int todayCount) {
        this.todayCount = todayCount;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public int getDayTask() {
        return dayTask;
    }

    public void setDayTask(int dayTask) {
        this.dayTask = dayTask;
    }

    public String getDict() {
        return dict;
    }

    public void setDict(String dict) {
        this.dict = dict;
    }
}
